package com.qf.hospital.mapper;

import com.qf.hospital.entity.SysRole;
import com.qf.hospital.entity.SysRoleExample;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface SysRoleMapper {
    long countByExample(SysRoleExample example);

    int deleteByExample(SysRoleExample example);

    int deleteByPrimaryKey(Integer roleId);

    int insert(SysRole record);

    int insertSelective(SysRole record);

    List<SysRole> selectByExample(SysRoleExample example);

    SysRole selectByPrimaryKey(Integer roleId);

    int updateByExampleSelective(@Param("record") SysRole record, @Param("example") SysRoleExample example);

    int updateByExample(@Param("record") SysRole record, @Param("example") SysRoleExample example);

    int updateByPrimaryKeySelective(SysRole record);

    int updateByPrimaryKey(SysRole record);

    @Select("select mid from sys_role_menu where rid = #{roleId}")
    List<Integer> findMenuByRoleId(@Param(value = "roleId") Integer roleid);

    @Delete("delete from sys_role_menu where rid = #{roleId}")
    void deleteByRoleId(@Param(value = "roleId") Integer roleid);

    int saveRoleMenu(@Param(value = "roleid") Integer roleid, @Param(value = "ids") Integer[] ids);

    @Update("update sys_role set available = '0' where role_id = #{roleid}")
    void deleteById(@Param("roleid") Integer roleid);
}